﻿using MixerReport.Common;
using MixerReport.Configs;
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Controls;

namespace MixerReport
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {

        /// <summary>
        /// 物料编码集
        /// </summary>
        public static MaterialConfig[]? Materials { get; set; }
        /// <summary>
        /// 搅拌机集
        /// </summary>
        public static MixerConfig[]? Mixers { get; set; }
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static string? DbConnectionString { get; set; }
        /// <summary>
        /// 应用 Frame
        /// </summary>
        public static Frame? AppFrame { get; private set; }
        /// <summary>
        /// 导航到
        /// </summary>
        /// <param name="pageName">页面名称</param>
        public static void Navigate(string pageName)
        {
            AppFrame?.Navigate(new Uri(pageName, UriKind.Relative));
        }

        /// <summary>
        /// 设置 Frame
        /// </summary>
        /// <param name="frame"></param>
        public static void SetFrame(object frame)
        {
            AppFrame = frame as Frame;
        }
        /// <summary>
        /// 等待设置 Frame
        /// </summary>
        /// <returns></returns>
        public static Task WaitSetFrameAsync()
        {
            return Task.Run(() =>
            {
                while (AppFrame == null) { }
            });
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {

        }

        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {

        }
    }

}
